package com.example.demo.kafkaConsumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @Author: dengkaibing
 * @Description: kafka消费者
 * @Date: 2021/9/21 16:01
 * @company 翼支付
 */
@Component
@Slf4j
public class KafkaConsumerListener {

    @KafkaListener(topics = "mall-trade-product")
    public void onMessage(ConsumerRecord<String,String> record){
        try {
            //消费者处理消息逻辑
            log.info("record:{}", record);
            log.info("消费者消费消息:{}", record.value());
        }catch (Exception e) {
            log.error("消费消息异常：",e);
        }
    }
}
